<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\grid\CGridView;
use yii\helpers\ArrayHelper;
use common\models\user\User;
use yii\helpers\Url;


/* @var $this yii\web\View */
/* @var $searchModel common\models\user\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '数据库管理');
$this->params['breadcrumbs'][] = $this->title;

?>

<?php $this->beginBlock('siderbar'); ?>
<?= $this->render('//layouts/sys-menu') ?>
<?php $this->endBlock(); ?>
<div class="user-index">
<style>

</style>
  <section class="content">
           <div class="row">
	<div class="col-xs-12">	
		<div class="box">
			<div class="box-header" style="zoom:1;overflow: hidden;">
				<h3 class="box-title" style="float:left;margin-right:10px;">
				<a onclick="return confirm('确定要备份数据库吗')" href="<?php echo '/dbmanage/backup/';?>" class="btn btn-primary">数据库备份</a>
				</h3>
				
			</div>
			<!-- /.box-header -->
			<div class="box-body">
				<table class="table table-bordered table-hover">
				<!-- 列表头部 -->
				<thead>
				<tr>
					<th>ID</th>
					<th>文件名</th>
					<th>备份时间</th>
					<th>文件大小</th>
					<th>操作</th>
				</tr>
				</thead>
				<!-- 列表头部 -->
				<?php
				if(!empty($fileinfo)){
					foreach($fileinfo as $_k => $vo) : ?>
				<!-- 循环列表 -->
				<tbody style="border:none">	
				<tr id="lista">
					<td><?= $_k+1; ?></td>
					<td><?= $vo['name']; ?></td>
					<td><?= $vo['time']; ?></td>
					<td><?= $vo['size']; ?></td>
					<td>
				<a onclick="return confirm('确定将当前备份还原到数据库吗？')" href="<?php echo '/dbmanage/restore/?name='.$vo['name']; ?>" class="btn btn-success btn-xs">还原</a>
	<a onclick="return confirm('确定删除该备份文件吗')" href="<?php echo '/dbmanage/del/?name='.$vo['name']; ?>" class="btn btn-info btn-xs">删除</a>
	<a onclick="return confirm('确定下载该备份文件吗')" href="<?php echo '/dbmanage/down/?file='.$vo['name']; ?>" class="btn btn-info btn-xs">下载</a>				
					</td>
				</tr>    
				</tbody>
				<?php endforeach; ?>
               <?php }else{?>
			   <tr><td colspan="5">没有找到相关数据。</td></tr>
               <?php } ?>		   
				<!-- 循环列表 END -->
				</table>
			</div>
			
		</div>
	</div>
</div>

 </section>
<script>
    $(document).ready(function(){
    	$('#gopage').click(function(){
			var selectpage = $('#selectpage').val();
			var selecturl = window.location.href;
			if(selecturl.indexOf("page=")>=0){
				selecturl = selecturl.replace(/page=\d*&per-page=/, "page=" + selectpage + "&per-page=");
			}else if(selecturl.indexOf("?")>=0){
				selecturl = selecturl + "&page=" + selectpage + "&per-page=10";
			}else{
				selecturl = selecturl + "?page=" + selectpage + "&per-page=10";
			}
			location.href = selecturl;
		});
    });
</script>
</div>